common/vcpu: Fix unintended breakage from cleanup
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 17 Feb 2017 11:53:44 +0000 (11:53 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 17 Feb 2017 13:01:56 +0000 (13:01 +0000)
c/s 3044a2a "common/vcpu: Switch v->vcpu_info_mfn to mfn_t" was intended to be
no functional change.

Unfortunately, because vcpu_info_reset() clobbers v->vcpu_info_mfn, the change
ended up calling put_page_and_type() on MFN_INVALID.

Reintroduce the local variable, and leave a comment behind.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/domain.c

index 0c52831eac14288b730d96be48d2abda5df53b3c..4492c9c3d5966b574beb03b7dc1abce1dee50391 100644 (file)
@@ -1211,15 +1211,17 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset)
  */
 void unmap_vcpu_info(struct vcpu *v)
 {
-    if ( mfn_eq(v->vcpu_info_mfn, INVALID_MFN) )
+    mfn_t mfn = v->vcpu_info_mfn;
+
+    if ( mfn_eq(mfn, INVALID_MFN) )
         return;
 
     unmap_domain_page_global((void *)
                              ((unsigned long)v->vcpu_info & PAGE_MASK));
 
-    vcpu_info_reset(v);
+    vcpu_info_reset(v); /* NB: Clobbers v->vcpu_info_mfn */
 
-    put_page_and_type(mfn_to_page(mfn_x(v->vcpu_info_mfn)));
+    put_page_and_type(mfn_to_page(mfn_x(mfn)));
 }
 
 int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)